package com.qf.springmvc;

import com.qf.pojo.User;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;


@RequestMapping("/resp")
//@Controller
//@ResponseBody//代表当前为方法都为响应正文
@RestController//Controller和ResponseBody的组合
public class RespBodyController {

    @RequestMapping("/test1")
    public String test1(){
        System.out.println("11111111111");
        return "success";
    }
    @RequestMapping("/test2")
    public User test2(){
        User user = new User();
        user.setAge(18);
        user.setName("小泥鳅");
        user.setHobby("吃胡萝卜");
        return user;
    }
    @RequestMapping("/test3")
    public Map test3(){
        HashMap<String, Object> map = new HashMap<>();
        map.put("name","小皮球");
        map.put("sex","女");


        return map;
    }
}
